From d7bcd93efcd4f1ae20678d0efa6777cfadc09a4e Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Fri, 10 Nov 2023 12:16:59 +0100 Subject: refactor(components): replace Overview with ProjectOverview component * `cover` prop is now expecting a ReactElement (NextImage) * `meta` prop is now limited to a specific set of meta items * add a `name` prop to add an accessible name to the figure element --- src/pages/projets/[slug].tsx | 162 +++++++++++-------------------------------- 1 file changed, 39 insertions(+), 123 deletions(-) (limited to 'src/pages/projets/[slug].tsx') diff --git a/src/pages/projets/[slug].tsx b/src/pages/projets/[slug].tsx index d397d27..58c03ce 100644 --- a/src/pages/projets/[slug].tsx +++ b/src/pages/projets/[slug].tsx @@ -12,19 +12,19 @@ import { Code, getLayout, Link, - Overview, PageLayout, Sharing, - SocialLink, Spinner, Heading, List, ListItem, Figure, type MetaItemData, - type MetaValues, Time, Grid, + ProjectOverview, + type ProjectMeta, + type Repository, } from '../../components'; import styles from '../../styles/pages/project.module.scss'; import type { NextPageWithLayout, ProjectPreview, Repos } from '../../types'; @@ -204,49 +204,37 @@ const ProjectPage: NextPageWithLayout = ({ project }) => { ); /** - * Retrieve the repositories links. + * Retrieve the project repositories. * * @param {Repos} repositories - A repositories object. - * @returns {MetaValues[]} - An array of meta values. + * @returns {Repository[]} - An array of repositories. */ - const getReposLinks = (repositories: Repos): MetaValues[] => { - const links: MetaValues[] = []; - const githubLabel = intl.formatMessage({ - defaultMessage: 'Github profile', - description: 'ProjectsPage: Github profile link', - id: 'Nx8Jo5', - }); - const gitlabLabel = intl.formatMessage({ - defaultMessage: 'Gitlab profile', - description: 'ProjectsPage: Gitlab profile link', - id: 'sECHDg', - }); + const getRepos = (repositories: Repos): Repository[] => { + const definedRepos: Repository[] = []; if (repositories.github) - links.push({ - id: 'github', - value: ( - - ), + definedRepos.push({ + id: 'Github', + label: intl.formatMessage({ + defaultMessage: 'Github profile', + description: 'ProjectsPage: Github profile link', + id: 'Nx8Jo5', + }), + url: repositories.github, }); if (repositories.gitlab) - links.push({ - id: 'gitlab', - value: ( - - ), + definedRepos.push({ + id: 'Gitlab', + label: intl.formatMessage({ + defaultMessage: 'Gitlab profile', + description: 'ProjectsPage: Gitlab profile link', + id: 'sECHDg', + }), + url: repositories.gitlab, }); - return links; + return definedRepos; }; const loadingRepoPopularity = intl.formatMessage({ @@ -269,95 +257,19 @@ const ProjectPage: NextPageWithLayout = ({ project }) => { if (isError) return 'Error'; if (isLoading || !data) return ; - const getRepoPopularity = (repo: string) => { - const stars = intl.formatMessage( - { - defaultMessage: - '{starsCount, plural, =0 {No stars on Github} one {# star on Github} other {# stars on Github}}', - description: 'ProjectsPage: Github stars count', - id: 'sI7gJK', - }, - { starsCount: data.stargazers_count } - ); - const popularityUrl = `https://github.com/${repo}/stargazers`; - - return ( - <> - ⭐  - {stars} - - ); - }; - - const overviewMeta: (MetaItemData | undefined)[] = [ - { - id: 'creation-date', - label: intl.formatMessage({ - defaultMessage: 'Created on:', - description: 'ProjectsPage: creation date label', - id: 'wVFA4m', - }), - value: